Hello,
//
//List Informationen zu Ordnern und Modulen in eine csv - Datei aus.
// Deactivate timeout for script execution
pragma runLim, 0;
//Activate the Autodeclarefunction
//XFLAGS_ &= ~AutoDeclare_
// Constants
const string dummy[] = {};
const int modListWidth = 500;
const int modWidth = 150;
const int pathWidth = (modListWidth - modWidth)/2;
const int viewWidth = modWidth;
const int listLength = 20;
const int MINI_EXP_FP = 1;
const int MINI_EXP_LINK_MODS = 2;
const int MINI_EXP_FORMAL_MODS = 4;
const int MINI_EXP_DESCRIPTIVE_MODS = 8;
const int MINI_EXP_SHOW_DELETED = 16;
// Variables
DB copyDB;
DBE modListDBE;
DBE viewListDBE;
DBE modFrameDBE;
DBE removeModuleDBE;
DBE addModuleDBE;
DBE viewFrameDBE;
DBE okBtnDBE;
DBE applyBtnDBE;
DBE miniExplorerDBE;
DBE dbeBrowse;
DBE dbeDirectory;
DBE PfadablageDBE;
DBE TextfeldDBE;
DBE dbeFrame;
DBE ButtonframeDBE;
DBE TestDBE;
int dataRow;
int moduleCount = 0;
int nos = 0;
int nospseicher = 0;
int itemMask = MINI_EXP_FORMAL_MODS;
Item folderItem
string selectedPfadDOORS = "";
string res = "";
string sep = "$";
string directoryName = "";
string Pfad_Name = "";
string log ="";
string result = "";
bool closeSrc;
Skip moduleList;
// Returns whether or not the selected item in the tree view matches the type of module the
// tree view was created to be able to select
bool itemMatchesSelectedMask(Item itm) {
bool matchesMask = false;
if(type(itm) == "Formal" && ((itemMask & MINI_EXP_FORMAL_MODS) == MINI_EXP_FORMAL_MODS)) {
matchesMask = true;
}
else if(type(itm) == "Link" && ((itemMask & MINI_EXP_LINK_MODS) == MINI_EXP_LINK_MODS)) {
matchesMask = true;
}
else if(type(itm) == "Descriptive" && ((itemMask & MINI_EXP_DESCRIPTIVE_MODS) == MINI_EXP_DESCRIPTIVE_MODS)) {
matchesMask = true;
}
return(matchesMask);
}
void addModuleToList(DBE clicked) {
string selectedModule = getRealPath(dbSep get(miniExplorerDBE));
Item i = item(selectedModule);
Project p = getParentProject(i);
bool moduleOpen = false;
int currentRow;
}
string getWindowsFolder(string &dirPath)
{
OleAutoObj objDialog = null
OleAutoObj objFolder = null
OleAutoObj objFolderItem = null
OleAutoArgs args = create
string folderPath = ""
string res = ""
dirPath = ""
objDialog = oleCreateAutoObject("Shell.Application")
if (null objDialog)
{
return("Failed to create dialog object")
}
put(args, 0) // always zero
put(args, "Wählen sie einen Pfad:") // title
put(args, 0) // options
//put(args, "c:\\temp") // root folder
res = oleMethod(objDialog, "BrowseForFolder", args, objFolder)
if (null objFolder)
{
if (res "" != "")
{
return("Failed to launch browser: " res)
}
else
{
return("")
}
}
res = oleGet(objFolder, "Self", objFolderItem)
if (null objFolderItem)
{
return("Failed to get folder item: " res)
}
oleGet(objFolderItem, "Path", folderPath)
dirPath = folderPath
return(res)
}
// Adds a new item to the tree view.
void addItemToTree(DBE dbe, Item i) {
string displayPath = getDisplayPath(i);
// check if the path exists in the tree view
if(exists(miniExplorerDBE, displayPath) == false) {
// check that the item is not deleted or if it is, that the tree view was created with the option
// to show deleted items.
if(isDeleted(i) == false || (isDeleted(i) == true && ((itemMask & MINI_EXP_SHOW_DELETED) == MINI_EXP_SHOW_DELETED))) {
// check item type
if(type(i) == "Folder" || type(i) == "Project") {
Icon iconOpen;
Icon iconClosed;
string sDummyEntry = displayPath dbSep dummyItem;
// assign project or folder specific icons
assignIcons(i, iconOpen, iconClosed);
// add entry (plus dummy)
insert(miniExplorerDBE, displayPath, iconClosed, iconOpen);
insert(miniExplorerDBE, sDummyEntry, iconClosed, iconOpen);
}
else {
if(itemMatchesSelectedMask(i)) {
insert(miniExplorerDBE, displayPath, getIcon(i), getIcon(i));
}
}
}
}
}
// Opens the selected Project or Folder in the tree view and loads its containing items.
void displaySelectedBranch(DBE dbe, string sItemPath) {
Folder fStart = folder(getRealPath(sItemPath));
if(fStart != null) {
Item i;
for i in all fStart do {
addItemToTree(miniExplorerDBE, i);
}
}
}
// DBE callback that fires when an element in the tree view is selected.
void doTreeSelect(DBE dbe) {
string sel = getRealPath(dbSep get(miniExplorerDBE));
}
// DBE callback that fires when an item in the tree view is double clicked.
bool doTreeExpand(DBE dbe, string sItem) {
string sItemPath = dbSep sItem;
string sDummyItem = sItemPath dbSep dummyItem;
// check status
if(exists(miniExplorerDBE, sDummyItem) == true) {
// remove dummy
delete(miniExplorerDBE, sDummyItem);
}
// check status
if(theCurrentView == DATABASE_VIEW) {
// adjust view accordingly
displaySelectedBranch(miniExplorerDBE, sItemPath);
}
else {
Project prjOldRoot = getRootProject_();
setRootProject_(project(getRootOfPath sItemPath));
// adjust view accordingly
displaySelectedBranch(miniExplorerDBE, sItemPath);
setRootProject_(prjOldRoot);
}
return(true)
}
// Loads the tree view to start with the passed in folder opened.
void changeToStartFolder(Folder fStart) {
if(!null fStart) {
int i;
// calculate max bound for loop
int finish = length(rootName_(fStart));
// prepare initial path
string sFolderPath = ((theCurrentView == DATABASE_VIEW) ? dbDisplayRoot() : "");
string sCharacter;
// process string
for(i = 0; i <= finish; i++) {
// obtain character
sCharacter = (rootName_(fStart))[i:i]
// check status
if(sCharacter == dbSep || i == finish) {
// check status
if(theCurrentView == PROJECT_VIEW && sFolderPath == dbSep) {
continue;
}
// update explorer
displaySelectedBranch(miniExplorerDBE, sFolderPath);
}
sFolderPath = sFolderPath sCharacter;
}
// update explorer
set(miniExplorerDBE, sFolderPath);
}
else {
// default to database level
displaySelectedBranch(miniExplorerDBE, dbDisplayRoot());
set(miniExplorerDBE, dbDisplayRoot());
}
}
void addModuleToList(DBE clicked) {
string modName;
string selectedPfadDOORS = getRealPath(dbSep get(miniExplorerDBE));
int currentRow;
currentRow = noElems(modListDBE);
insert(modListDBE, currentRow, selectedPfadDOORS);
setCheck(modListDBE, currentRow, true)
active(applyBtnDBE);
}
void closeDB(DB dbox) {
hide(dbox);
destroy(dbox);
dbox = null;
}
void createReportLine(Item i)
{
//Buffer result = create();
ModuleVersion mv = moduleVersion(module fullName(i))
ModuleProperties mp
getProperties (mv, mp)
result = stringOf(today) sep
result = result name i sep
result = result rootName_ i sep
result = result uniqueID(i) sep
AttrDef adCurrent = null
adCurrent = find(mp, "Module Type")
if (adCurrent == null){
result =result "NULL" sep sep
}
else{
string modType = mp."Module Type"
result = result modType sep
// Evaluate baselines for FI Modules only
if(modType == "FI Module"){
Module currModule = read(fullName i, false, false)
Baseline b
for b in currModule do {
result =result (major b) "." (minor b) (suffix b) " @@ "
}
close(currModule, false)
result = result sep
}
else{
result = result sep
}
}
result = result mp."Last Modified On" sep
result = result mp."Last Modified By" sep
result = result description i sep
result = result getURL i sep
result = result mp."Created On" sep
result = result mp."Created By" sep
result = result "\n"
out << result;
flush out;
flushDeletions();
//delete result;
}
void processBar(Folder f)
{
for folderItem in f do {
if(isDeleted(folderItem))
continue
if(type folderItem == "Formal"){
nos++;
}
if(type folderItem == "Project"){
processBar(folder(fullName folderItem));
}
if(type folderItem == "Folder"){
processBar(folder(fullName folderItem));
}
}
}
void processFolder(Folder f)
{
for folderItem in f do {
if(isDeleted(folderItem))
continue
if(type folderItem == "Formal"){
moduleCount++
progressStep ++nos
createReportLine(folderItem)
}
if(type folderItem == "Project"){
processFolder(folder(fullName folderItem))
}
if(type folderItem == "Folder"){
processFolder(folder(fullName folderItem))
}
if (progressCancelled) {
progressStop;
log = log "Sie haben den Export bei " moduleCount " von " nospseicher " Modulen abgebrochen." "\n";
log = log "Die abgebrochene Exportdatei wurde gespeichert unter: " Pfad_Name "\n";
set(TextfeldDBE,log);
//set(TextfeldDBE, "Sie haben den Export bei " moduleCount " von " nospseicher " Modulen abgebrochen. Die Exportdatei wurde gespeichert unter: " Pfad_Name );
moduleCount = 0;
nos = 0 ;
halt;
}
}
log = "Exportumfang analysiert, export läuft" "\n" moduleCount " Module" " von insgesamt " nospseicher " exportiert." "\n" "Die Exportdatei wird erstellt nach: " Pfad_Name "\n";
set(TextfeldDBE,log);
}
void Exportstart(DB dbox) {
set(TextfeldDBE,"");
Pfad_Name = get PfadablageDBE;
Buffer intro = create();
Stream out = write(Pfad_Name);
intro = "Created on"sep"Module Name"sep"Root Name"sep"UniqueID"sep"Module Type"sep"Baseline"sep"Last Modified On"sep"Last Modified By"sep"Description"sep"URL"sep"Created On"sep"Created By\n"
out << intro;
delete intro;
int i = 0
selectedPfadDOORS = getColumnValue(modListDBE, i, 0)
Folder f = folder(selectedPfadDOORS)
log = "#SCRIPT arbeitet, bitte warten Sie. " "\n";
set(TextfeldDBE,log);
for (i < noElems(modListDBE); i++){
set (modListDBE, i, 1, "Wird Analysiert");
selectedPfadDOORS = getColumnValue(modListDBE, i, 0)
Folder f = folder(selectedPfadDOORS)
// Loop through folders and subfolder (recursive)
processBar(Folder f);
nospseicher = nos;
set (modListDBE, i, 1, "Analysiert, warte auf Export");
}
log = log "Exportumfang wurde analysiert, keinen Fehler gefunden" "\n";
set(TextfeldDBE,log);
progressStart(copyDB, "Export fortschritt", "" ,nos) ;
nos = 0;
i = 0
for (i < noElems(modListDBE); i++){
set (modListDBE, i, 1, "Wird Exportiert");
selectedPfadDOORS = getColumnValue(modListDBE, i, 0)
Folder f = folder(selectedPfadDOORS)
processFolder(Folder f)
set (modListDBE, i, 1, "Exportiert");
}
log = log "Exportdatei fertig gestellt: " "\n" "Datei liegt unter:" Pfad_Name "\n";
set(TextfeldDBE,log);
progressStop;
moduleCount = 0;
nos = 0 ;
nospseicher = 0;
i = 0;
}
void deleteTest (DBE clicked){
//int selectedRow = get(modListDBE);
//string moduleName = getColumnValue(modListDBE, selectedRow, 1);
// Muss angepasst werden, Listview durchlauf löscher
int i = -1
for (i < noElems(modListDBE); i++){
delete(modListDBE, i);
//setCheck(modListDBE, i, false) //für setCheck i=-1 Auskommentieren
i =-1
}
inactive(applyBtnDBE);
}
void buildDB() {
string projectName = "";
Project projectRoot = null;
copyDB = create("Exportscript für REQUEST", styleCentered);
dbeFrame = frame(copyDB, "Exportscript", 400, 580);
dbeFrame->"top"->"form"
dbeFrame->"left"->"form"
dbeFrame->"right"->"form"
dbeFrame->"bottom"->"form"
modFrameDBE = frame(copyDB, "Select DOORS Pfad für Export", 400, 420);
modFrameDBE->"top"->"inside"->dbeFrame
modFrameDBE->"left"->"inside"->dbeFrame
modFrameDBE->"right"->"inside"->dbeFrame
modFrameDBE->"bottom"->"unattached"
ButtonframeDBE = frame(copyDB, "Buttons", 400 ,100 );
ButtonframeDBE->"top"->"flush"->modFrameDBE
ButtonframeDBE->"left"->"inside"->dbeFrame
ButtonframeDBE->"right"->"inside"->dbeFrame
ButtonframeDBE->"bottom"->"inside"->dbeFrame
miniExplorerDBE = treeView(copyDB, treeViewOptionSorted, 0, 10);
miniExplorerDBE->"top"->"inside"->modFrameDBE
miniExplorerDBE->"left"->"inside"->modFrameDBE
miniExplorerDBE->"right"->"inside"->modFrameDBE
miniExplorerDBE->"bottom"->"unattached"
PfadablageDBE = fileName(copyDB, "Export to:", "C:/Documents and Settings/All Users/Desktop/" "Export.csv", "*.csv", "Excel Files", false)
PfadablageDBE->"top"->"flush"->miniExplorerDBE
PfadablageDBE->"left"->"inside"->modFrameDBE
PfadablageDBE->"right"->"inside"->modFrameDBE
PfadablageDBE->"bottom"->"unattached"
modListDBE = listView(copyDB, listViewOptionCheckboxes | listViewOptionMultiselect, 400, 8, dummy)
modListDBE->"top"->"flush"->PfadablageDBE
modListDBE->"left"->"inside"->modFrameDBE
modListDBE->"right"->"inside"->modFrameDBE
modListDBE->"bottom"->"unattached"
removeModuleDBE = button(copyDB, "Exportinhalt definieren", addModuleToList, true, 100);
removeModuleDBE->"top"->"inside"->ButtonframeDBE
removeModuleDBE->"left"->"inside"->ButtonframeDBE
removeModuleDBE->"right"->"unattached"
removeModuleDBE->"bottom"->"inside"->ButtonframeDBE
TestDBE = button(copyDB, "Reset Exportliste", deleteTest, true, 100);
TestDBE->"top"->"inside"->ButtonframeDBE
TestDBE->"left"->"flush"->removeModuleDBE
TestDBE->"right"->"unattached"
TestDBE->"bottom"->"inside"->ButtonframeDBE
TextfeldDBE = text(copyDB, "Logfenster", "",150, true);
TextfeldDBE->"top"->"flush"->removeModuleDBE
TextfeldDBE->"left"->"inside"->ButtonframeDBE
TextfeldDBE->"right"->"inside"->ButtonframeDBE
TextfeldDBE->"bottom"->"inside"->ButtonframeDBE
applyBtnDBE = apply(copyDB, "Exportstart", Exportstart);
close(copyDB, true, closeDB);
inactive(applyBtnDBE);
realize(copyDB);
set(miniExplorerDBE, doTreeSelect);
set(miniExplorerDBE, doTreeExpand);
insertColumn(modListDBE, 0, "Project Pfad", 450, iconProject);
insertColumn(modListDBE, 1, "Status", 130, iconNone);
// check status
if(theCurrentView == DATABASE_VIEW) {
insert(miniExplorerDBE, dbDisplayRoot(), iconDatabase, iconDatabase);
}
else {
projectRoot = getRootProject_();
setRootProject_(null);
// process database
for projectName in database do {
addItemToTree(miniExplorerDBE, item(dbSep projectName));
}
setRootProject_(projectRoot);
}
changeToStartFolder(current Folder);
}
// Main
buildDB();
show(copyDB);
Mr.DJ - Thu Nov 24 06:43:46 EST 2011 |
Re: DOORS memory problem that you will need to invest some work to make it work on very large projects. Having scripts work on large projects and handle a lot of data is not easy in DXL. The following rules apply (and are violated by your code):
That is all I see on a first glance, Regards, Mathias Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS |
Re: DOORS memory problem
Hello,
void createReportLine(Item i)
{
Buffer result = create();
ModuleVersion mv = moduleVersion(module fullName(i))
ModuleProperties mp
getProperties (mv, mp)
result = stringOf(today) sep
result += name i sep
result += rootName_ i sep
result += uniqueID(i) sep
AttrDef adCurrent = null
adCurrent = find(mp, "Module Type")
if (adCurrent == null){
result = "NULL" sep sep
}
else{
string modType = mp."Module Type"
result += modType sep
// Evaluate baselines for FI Modules only
if(modType == "FI Module"){
Module currModule = read(fullName i, false, false)
Baseline b
for b in currModule do {
result += (major b) "." (minor b) (suffix b) " @@ "
}
close(currModule, false)
result += sep
}
else{
result += sep
}
}
result += mp."Last Modified On" sep
result += mp."Last Modified By" sep
result += description i sep
result += getURL i sep
result += mp."Created On" sep
result += mp."Created By" sep
result = "\n"
//out << result;
delete result;
}
|
Re: DOORS memory problem Mr.DJ - Thu Nov 24 09:17:28 EST 2011
Hello,
void createReportLine(Item i)
{
Buffer result = create();
ModuleVersion mv = moduleVersion(module fullName(i))
ModuleProperties mp
getProperties (mv, mp)
result = stringOf(today) sep
result += name i sep
result += rootName_ i sep
result += uniqueID(i) sep
AttrDef adCurrent = null
adCurrent = find(mp, "Module Type")
if (adCurrent == null){
result = "NULL" sep sep
}
else{
string modType = mp."Module Type"
result += modType sep
// Evaluate baselines for FI Modules only
if(modType == "FI Module"){
Module currModule = read(fullName i, false, false)
Baseline b
for b in currModule do {
result += (major b) "." (minor b) (suffix b) " @@ "
}
close(currModule, false)
result += sep
}
else{
result += sep
}
}
result += mp."Last Modified On" sep
result += mp."Last Modified By" sep
result += description i sep
result += getURL i sep
result += mp."Created On" sep
result += mp."Created By" sep
result = "\n"
//out << result;
delete result;
}
Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS |
Re: DOORS memory problem Mr.DJ - Thu Nov 24 09:17:28 EST 2011
Hello,
void createReportLine(Item i)
{
Buffer result = create();
ModuleVersion mv = moduleVersion(module fullName(i))
ModuleProperties mp
getProperties (mv, mp)
result = stringOf(today) sep
result += name i sep
result += rootName_ i sep
result += uniqueID(i) sep
AttrDef adCurrent = null
adCurrent = find(mp, "Module Type")
if (adCurrent == null){
result = "NULL" sep sep
}
else{
string modType = mp."Module Type"
result += modType sep
// Evaluate baselines for FI Modules only
if(modType == "FI Module"){
Module currModule = read(fullName i, false, false)
Baseline b
for b in currModule do {
result += (major b) "." (minor b) (suffix b) " @@ "
}
close(currModule, false)
result += sep
}
else{
result += sep
}
}
result += mp."Last Modified On" sep
result += mp."Last Modified By" sep
result += description i sep
result += getURL i sep
result += mp."Created On" sep
result += mp."Created By" sep
result = "\n"
//out << result;
delete result;
}
Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS |
Re: DOORS memory problem Mr.DJ - Thu Nov 24 09:17:28 EST 2011
Hello,
void createReportLine(Item i)
{
Buffer result = create();
ModuleVersion mv = moduleVersion(module fullName(i))
ModuleProperties mp
getProperties (mv, mp)
result = stringOf(today) sep
result += name i sep
result += rootName_ i sep
result += uniqueID(i) sep
AttrDef adCurrent = null
adCurrent = find(mp, "Module Type")
if (adCurrent == null){
result = "NULL" sep sep
}
else{
string modType = mp."Module Type"
result += modType sep
// Evaluate baselines for FI Modules only
if(modType == "FI Module"){
Module currModule = read(fullName i, false, false)
Baseline b
for b in currModule do {
result += (major b) "." (minor b) (suffix b) " @@ "
}
close(currModule, false)
result += sep
}
else{
result += sep
}
}
result += mp."Last Modified On" sep
result += mp."Last Modified By" sep
result += description i sep
result += getURL i sep
result += mp."Created On" sep
result += mp."Created By" sep
result = "\n"
//out << result;
delete result;
}
Once you converted "result" to a Buffer I don't see an exponential problem, but I do see these small ones:
-Louie |